using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Employers_jobdetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["rcuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        Session["rcCurrentPage"] = Request.ServerVariables.Get("URL")
        + "?" + Request.ServerVariables.Get("QUERY_STRING"); ;
        if (!IsPostBack)
        {            
            try
            {
                string jobID = Request.QueryString.Get("JobID");
                 
                string fromPage = Request.QueryString.Get("page");                           
                if (jobID != null && jobID != "")
                {
                    ShowDetails(jobID);
                    if(DetailsView1.Rows[19].Cells[1].Text == "1")
                        Literal1.Text =  
                        "<input type=button "+
                        "value='Apply online' "+
                        "onclick =\"window.open('"+
                        "http://www.huukhang.com/"+
                        "job.aspx?JobId=" + 
                        DetailsView1.Rows[2].Cells[1].Text  
                        + "');\">";
                    txtJobID.Text = jobID;
                    
                }
                else
                    Response.Redirect("myaccount.aspx"); 
                
                Literal1.Text += "  <input type=button "+
                        "value='Back' "+
                        "onclick =\"window.history.go(-1);\">";
            }
            catch (Exception ex)
            {
                litError.Text = ex.Message;
            }
        }
    }
    void ShowDetails(string jobID)
    {
        try
        {
            ControlHelper cls = new ControlHelper("");
            cls.CommandText = "SPViewJobDetails";
            cls.ParameterCollection = new string[1] { "@JobID" };
            cls.ValueCollection = new string[1] { jobID};
            cls.CommandType = CommandType.StoredProcedure;
            cls.InitProperties();
            cls.FillDataTableToDetailsView(this.DetailsView1);
        }
        catch (Exception ex)
        {
            litError.Text = ex.Message;
        }
    }
     
}
